<?php
/* -----------------------------------------------------------------
 *                        Aveghe My Blog
 * -----------------------------------------------------------------
 * Aveghe My Blog: made your blog easy!
 * Copyright (C) 2008 Elia Contini
 * 
 * Aveghe My Blog is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * Aveghe My Blog is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */

$baseURL = BASE_URL;

$meta    = $this->head('meta'   , 'public', $this->preferences);
$style   = $this->head('style'  , 'public', $this->preferences);
$favicon = $this->head('favicon', 'public', $this->preferences);
$rss     = $this->head('rss'    , 'public', $this->preferences);

$siteTitle = '<h1><a href="'.$baseURL.'/" title="">'.stripcslashes($this->preferences['site_title'])."</a></h1>\n";

$report = '';
$content = '';

if(count($this->searchResult) == 0) 
	$content = 'La ricerca non ha prodotto alcun risultato';
else
	{
		$content .= "<h2>Risulti della ricerca</h2>\n";
		$content .= "<ul id=\"searchResult\">\n";
		foreach($this->searchResult as $result)
			{
				$content .= "\n\t<li><a href=\"".$baseURL."/post/view/id/".$result['document_id']."\" title=\"\">".stripcslashes($result['document_name'])."</a></li>\n";
			}
		$content .= "</ul>\n";
	}
	
// pages
if($this->pageNum > 1)
	{
		$searchKeys = '';
		for($i = 0; $i < count($this->searchKeys); $i++)
			{
				$searchKeys .= $this->searchKeys[$i];
				if(($i + 1) < count($this->searchKeys))
					$searchKeys .= '+';
			}
		
		$content .= "\n\t<p id=\"pagesIndex\">";
		for($i = 0; $i < $this->pageNum; $i++)
			{
				if($i == $this->currentPage)
					$content .= "\n\t\t<strong>".($i + 1).'</strong>';
				else
					$content .= "\n\t\t<a href=\"".$baseURL.'/search/?page='.$i.'&amp;searchKeys='.$searchKeys.'" title="Risultati ricerca: pagina '.($i + 1).'">'.($i + 1).'</a>';
					
				if(($i + 1) < $this->pageNum)
					$content .= ' <span class="hidden">|</span> ';
			}
		$content .= "\n\t</p>\n";
	}

$categories = $this->categoriesList($this->categories, 0);
 
include 'aveghe/themes/public/'.$this->preferences['site_public_theme'].'/template_public.xhtml';
?>